package com.ofek.applicationbase.utils;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.sql.Date;
import java.text.SimpleDateFormat;

public class Log {
	public static void d(final Object... objs) {
		final StringBuilder stringBuilder = new StringBuilder();
		
		stringBuilder.append(getTS());
		for (final Object o : objs) {
			stringBuilder.append(' ');
			stringBuilder.append(DebugUtils.toString(o));
		}
		final String className = Thread.currentThread().getStackTrace()[3].getClassName();
		android.util.Log.d(className,stringBuilder.toString());
	}
	private static String getTS() {
		final SimpleDateFormat sdf = new SimpleDateFormat("dd-M-yyyy hh:mm:ss");
		final String date = sdf.format(new Date(System.currentTimeMillis())); 
		return date;
	}
	public static void d(final Exception e) {
		final StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.append(getTS());
		final StringWriter sw = new StringWriter();
		final PrintWriter pw = new PrintWriter(sw);
		e.printStackTrace(pw);
		final String className = Thread.currentThread().getStackTrace()[3].getClassName();
		android.util.Log.d(className,stringBuilder.toString());
	}

	public static void d(final String string) {
		android.util.Log.d(Thread.currentThread().getStackTrace()[3].getClassName(),string);
	}
	public static void d(final String tag, final String string) {
		android.util.Log.d(tag,string);

	}
}
